package main

import (
	"errors"
	"fmt"
)

func main() {
	map_test()
	type_convert()
}

func map_test() {
	//声明map定义，此时为nil
	var data map[string]string
	var mymap map[string]string
	fmt.Println(mymap == nil)
	fmt.Println(mymap)

	//初始化
	data = make(map[string]string)
	fmt.Println(data == nil)
	fmt.Println(data)

	data["name"] = "test"

	//向map添加值
	data["name"] = "mark"
	for index, value := range data {
		fmt.Println(index)
		fmt.Println(value)
	}
}

func type_convert() {
	var score int = 120
	var weight int = 50
	var rate float32
	rate = float32(score) / float32(weight)
	fmt.Println(rate)

}

//下面开始error相关

func get_error_msg() (string, error) {
	if 8 > 0 {
		return "faild", errors.New()
	}
}
